package com.example.demo.service;
import com.example.demo.mapper.UserInfoMapper;
import com.example.demo.model.UserInfo;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public List<UserInfo> getAllUser() {
        return userInfoMapper.selectAll();
    }

    public UserInfo getUserInfoById(Integer id) {
        return userInfoMapper.selectAllById(id);
    }

    public UserInfo queryUserByUserNameAndPassword(String username, String password) {
        List<UserInfo> userInfos= userInfoMapper.selectByNameAndPassword2(username, password);
        if(userInfos!=null&&userInfos.size()>=1){
            return userInfos.get(0);
        }
        return null;
    }
}

